const jinglingObj = {
    start() {
        if (!common.beforeRun("jingling")) {
            return
        }
        logd(androidObj.num+"执行精灵");
        utils.openAppByName("精灵代挂")
        sleep(5000)
        swipeToPoint(350, 1000, 350, 200, 200)
        sleep(2000)
        common.findClick("text", "启动程序")
        var times = 0;
        while(times<=5) {
            this.wuzhangai();
            sleep(2000)
            times++;
        }
    },
    stop() {
        if (!common.beforeRun("jingling")) {
            return
        }
        logd(androidObj.num+"停止精灵");
        common.findClick("text", "停止")
        sleep(1000)
        home()
        sleep(1000)
        common.findClick("id", "com.gibb.easyclick:id/close_iv")
        sleep(2000)
        recentApps();
        sleep(500)
        common.findClick("id", "com.huawei.android.launcher:id/clear_all_recents_image_button")
    },
    wuzhangai() {
        if (!common.beforeRun("jingling")) {
            return
        }
        var selector = text("无障碍").getNodeInfo(1000)
        if (selector) {
            swipeToPoint(350, 1000, 350, 200, 500)
            sleep(1000)
            swipeToPoint(350, 1000, 350, 200, 500)
            sleep(1000)
            swipeToPoint(350, 1000, 350, 200, 500)
            sleep(1000)
            swipeToPoint(350, 1000, 350, 200, 500)
            sleep(1000)
            swipeToPoint(350, 1000, 350, 200, 500)
            sleep(1000)
            swipeToPoint(350, 1000, 350, 200, 500)
            sleep(1000)
            text("已安装的服务")
            common.findClick("text", "已安装的服务")
            sleep(1000)
            common.findClick("text", "精灵代挂")
            sleep(1000)
            common.findClick("id", "android:id/switch_widget")
            sleep(1000)
            common.findClick("text", "确定")
            sleep(1000)
            back()
            sleep(500)
            back()
            sleep(500)
            back()
            sleep(500)
            this.start()
        }
    }
}
module.exports = jinglingObj